<!DOCTYPE HTML>

<!--
 ______________ 
< TUICOOL.COM >
 -------------- 
        \   ^__^
         \  (**)\__$__$__
            (__)\       )\/\
             U  ||------|
                ||     ||
-->
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta content="authenticity_token" name="csrf-param" />
<meta content="UZjYzG+evANVldNol4aFKUps6epztYKGUgfUh+Z7Q20=" name="csrf-token" />
    <title>
            UITableView：下拉刷新和上拉加载更多 - cDigger - 推酷
   </title>
    <meta name="description" content="UITableView：下拉刷新和上拉加载更多 - cDigger"/>
  <link rel="shortcut icon" href="http://static0.tuicool.com/favicon.ico" type="image/x-icon" />
  <link href="http://asset.tuicool.com/assets/application-0d4e8cad524c6308f5082fe6be9560f8.css" media="screen" rel="stylesheet" type="text/css" />
  <link href="http://static0.tuicool.com/assets/font-awesome.min.css" rel="stylesheet">
  <script src="http://asset.tuicool.com/assets/application-5272668a8ed427c5225cac7c6110da64.js" type="text/javascript"></script>

  <!--[if IE 7]>
  <link rel="stylesheet" href="http://assets.tuicool.com/assets/font-awesome-ie7.min.css">
  <![endif]--> 
    <script type="text/javascript" src="http://static2.tuicool.com/assets/tip.js?t=3"></script>
  
  <script type="text/javascript" src="http://cbjs.baidu.com/js/m.js"></script>
<script src="http://dup.baidustatic.com/js/ds.js"></script>
<script type="text/javascript" src="http://static1.tuicool.com/assets/spin.min.js"></script>
<link rel="stylesheet" href="http://static0.tuicool.com/assets/github.css">

</head>
<body>
  
  <div id="header" class="navbar-fixed-top">
    <div class="container">
      <div class="navbar">
        <div class="navbar-inner">
          <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse"> 
            <span class="icon-bar"></span> 
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span> 
          </a>
          <a href="http://www.tuicool.com/" class="brand">推酷</a>        
        <nav class="nav-collapse collapse">
            <ul class="nav navbar primary-nav">                            
              <li class="active">
                <a href="http://www.tuicool.com/ah">
                  文章
                </a>
              </li>              
              <li class="">
                <a href="http://www.tuicool.com/sites/hot">
                  站点
                </a>
              </li>
              <li class="">
                <a href="http://www.tuicool.com/topics">
                  主题
                </a>
              </li>
              <li class="">
                <a href="http://course.tuicool.com/">
                  公开课
                </a>
              </li>
              <li class="">
                <a href="http://huodong.tuicool.com/">
                  活动
                </a>
              </li>
              <li class="">
                <a href="http://www.tuicool.com/mobile">
                  客户端
                    <sup style="font-size:0.8em;color: #16A085;">荐</sup>
                </a>
              </li>
              <li class="dropdown  ">
                <a href="#" class="dropdown-toggle" data-toggle="dropdown">周刊 <b class="caret"></b></a>
                <ul class="dropdown-menu">
                  <li><a href="http://www.tuicool.com/mags">编程狂人</a></li>
                  <li><a href="http://www.tuicool.com/mags/design">设计匠艺</a></li> 
                  <li><a href="http://www.tuicool.com/articles/weekly">一周拾遗</a></li>                  
                </ul>
              </li>
              
               <li class="dropdown  ">
                <a href="#" class="dropdown-toggle" data-toggle="dropdown">更多 <b class="caret"></b></a>
                <ul class="dropdown-menu">
                  <li><a href="http://www.tuicool.com/bbs">讨论区</a></li>  
                  <li><a href="http://www.tuicool.com/about">关于我们</a></li>                 
                </ul>
              </li>
              
              </ul>
            <form class="navbar-search pull-left" action="http://www.tuicool.com/search">
              <input type="text" class="search-query span2" name="kw" placeholder="搜索">
            </form>
            <ul class="nav pull-right">
                <li><a href="http://www.tuicool.com/login">登录</a></li>
            </ul>
          </nav>
        </div>
      </div>
  </div>   
</div>
  <div id ="flash_container" class="noPrint">    
  </div>
  
  <div class="container-fluid">  
    <div class="row-fluid article_row_fluid">
    <div class="span8 contant article_detail_bg">
        <h1>UITableView：下拉刷新和上拉加载更多 - cDigger</h1>
        <div class="article_meta">
            <div style="margin-bottom: 5px;">
            <span class="timestamp">时间&nbsp;2013-11-24 02:00:00
            </span>
            <span class="from">
                <i class="icon-globe"></i>
                    <a class="cut cut28 from" href="/sites/bAzeYv" target="_blank">博客园精华区
                    </a>
            </span>
            </div>
            <div class="source">
                <i style="float:left;">原文</i>&nbsp; 
                <a class="cut cut70" href="http://www.cnblogs.com/lexingyu/p/3439707.html?utm_source=tuicool" style="display:inline-block;">http://www.cnblogs.com/lexingyu/p/3439707.html</a>
            </div>
            <div>
                <span>主题</span>
                <a href="/topics/11350069" target='_blank' >
                    <span class="new-label">UITableView</span>
                </a>
            </div>
        </div>
        <div class="article_body" id="nei">
            <div>
  <p>
    <span>
      <strong>【转载请注明出处】</strong>
    </span>
  </p>
  <p>
    <span>本文将说明让UIScrollView支持&quot;下拉刷新&quot;和&quot;上拉加载更多&quot;的实现机制，并实现一个可用的tableView子类，以下主要以&quot;下拉刷新&quot;进行说明。</span>
  </p>
  <p>
    <span>工程地址在帖子最下方，只需要代码的直拉到底即可。</span>
  </p>
  <p>
    <strong>
      <span>1、contentInset和下拉刷新</span>
    </strong>
  </p>
  <p>
    <span>contentInset是UIScrollView的属性，它描述了UIScrollView的内容View的内边距，具体可见官方文档：</span>
  </p>
  <p>
    <a href="https://developer.apple.com/library/ios/documentation/windowsviews/conceptual/UIScrollView_pg/CreatingBasicScrollViews/CreatingBasicScrollViews.html" target="_blank" rel="nofollow">
      <span>Scroll View programming Guide for iOS</span>
    </a>
  </p>
  <p>
    <span>目前几乎所有&quot;下拉刷新&quot;的第三方库都是依赖它实现的。</span>
  </p>
  <p>
    <span>
      【为便于讨论，将下拉刷新/上拉加载时显示的视图称为refresh panel，如下图】      <br/>
      <img src="http://img1.tuicool.com/JbARrm.png" alt="" class="alignCenter" />
      <br/>
    </span>
  </p>
  <p>在用户手指向下滑动到最终更新界面的过程中，经历了4个步骤：</p>
  <p>（1）随着用户下拉逐渐显示UITableView顶部的refresh panel；</p>
  <p>（2a）下拉达到预设位置，状态文字变为&quot;松开可以刷新&quot;;</p>
  <p>（2b）下拉未达到预设位置，用户手指离开屏幕，ScrollView弹回，refresh panel重新隐藏起来，结束。</p>
  <p>（3）用户手指离开屏幕，refresh panel保持显示。状态文字变为&quot;加载中&quot;，在后台执行更新数据的操作；</p>
  <p>（4）数据更新完成，返回主线程，重新隐藏refresh panel，结束。</p>
  <p>可以看到，如果不考虑刷新时间、状态文字等，实现&quot;下拉刷新&quot;实际上只需要做到2件事：</p>
  <p>（1）隐藏refresh panel（初始时和刷新后）</p>
  <p>隐藏refresh panel，即使其居于UITableView的上方且不可见，如下</p>
  <div>
    <pre class="prettyprint"><span style="color: #008080;"> 1</span> - (<span style="color: #0000ff;">void</span><span style="color: #000000;">)addDragHeaderView
</span><span style="color: #008080;"> 2</span> <span style="color: #000000;">{
</span><span style="color: #008080;"> 3</span>     <span style="color: #0000ff;">if</span> (self.shouldShowDragHeader &amp;&amp; !<span style="color: #000000;">dragHeaderView)
</span><span style="color: #008080;"> 4</span> <span style="color: #000000;">    {
</span><span style="color: #008080;"> 5</span>         CGRect frame = CGRectMake(<span style="color: #800080;">0</span>, -<span style="color: #000000;">self.dragHeaderHeight,
</span><span style="color: #008080;"> 6</span> <span style="color: #000000;">                                    self.bounds.size.width, self.dragHeaderHeight);
</span><span style="color: #008080;"> 7</span>         dragHeaderView =<span style="color: #000000;"> [[Pull2RefreshView alloc]
</span><span style="color: #008080;"> 8</span> <span style="color: #000000;">                                    initWithFrame:frame type:kPull2RefreshViewTypeHeader];
</span><span style="color: #008080;"> 9</span> <span style="color: #000000;">        [self addSubview:dragHeaderView];
</span><span style="color: #008080;">10</span> <span style="color: #000000;">    }
</span><span style="color: #008080;">11</span> }</pre>
  </div>
  <p>
    【    <strong>注意</strong>
    ：不应使用UITableView的tableHeaderView来作为refresh panel，一来会使得下拉刷新和自定义tableHeaderView无法共存，二来UITableView的内容视图是包含tableHeaderView的，即  </p>
  <p>tableView.contentSize.height == tableView.tableHeaderView.height</p>
  <p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; + n * sectionHeaderView.height</p>
  <p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; + m * cell.height</p>
  <p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; + tableView.tableFooterView.height</p>
  <p>因此想让tableHeaderView默认不可见，需要修改contentOffset的初始值并在用户滑动时控制滑动范围，非常麻烦。】</p>
  <p>（2）显示refresh panel</p>
  <p>当用户手指下拉达到预设值并离开屏幕，立即修改contentInset，使refresh panel保持显示，如下</p>
  <div>
    <pre class="prettyprint"><span style="color: #008080;">1</span> - (<span style="color: #0000ff;">void</span>)scrollViewDidEndDragging:(UIScrollView *<span style="color: #000000;">)scrollView willDecelerate:(BOOL)decelerate
</span><span style="color: #008080;">2</span> <span style="color: #000000;">{
</span><span style="color: #008080;">3</span>         <span style="color: #0000ff;">if</span> (scrollView.contentOffset.y &lt; -self.dragHeaderHeight - <span style="color: #800080;">10.0f</span>
<span style="color: #008080;">4</span> <span style="color: #000000;">        {
</span><span style="color: #008080;">5</span>             <span style="color: #008000;">//</span><span style="color: #008000;">使refresh panel保持显示</span>
<span style="color: #008080;">6</span>             self.contentInset = UIEdgeInsetsMake(self.dragHeaderHeight, <span style="color: #800080;">0</span>, <span style="color: #800080;">0</span>, <span style="color: #800080;">0</span><span style="color: #000000;">);
</span><span style="color: #008080;">7</span> <span style="color: #000000;">        }
</span><span style="color: #008080;">8</span> }</pre>
  </div>
  <p>如此，更新数据后再次隐藏refresh panel的方式也很明了</p>
  <div>
    <pre class="prettyprint"><span style="color: #008080;">1</span> self.contentInset = UIEdgeInsetsZero;</pre>
  </div>
  <p>
    <span>
      <strong>2、动画、动态文字和刷新时间</strong>
    </span>
  </p>
  <p>一个标准的refresh panel（如新浪微博的），包含指示箭头、加载菊花、状态文字和更新时间四部分，如下</p>
  <div>
    <pre class="prettyprint"><span style="color: #008080;"> 1</span> <span style="color: #0000ff;">@implementation</span><span style="color: #000000;"> Pull2RefreshView
</span><span style="color: #008080;"> 2</span> <span style="color: #000000;">{
</span><span style="color: #008080;"> 3</span>     UILabel     *<span style="color: #000000;">hintLabel;
</span><span style="color: #008080;"> 4</span>     UILabel     *<span style="color: #000000;">timeLabel;
</span><span style="color: #008080;"> 5</span>     
<span style="color: #008080;"> 6</span>     UIImageView             *<span style="color: #000000;">arrowImageView;
</span><span style="color: #008080;"> 7</span>     UIActivityIndicatorView *<span style="color: #000000;">indicatorView;
</span><span style="color: #008080;"> 8</span>     
<span style="color: #008080;"> 9</span> <span style="color: #000000;">    Pull2RefreshViewType refreshType;
</span><span style="color: #008080;">10</span> }</pre>
  </div>
  <p>在1中已经做到了refresh panel的显示的隐藏，2中只需要在合适的时候改变refresh panel的显示内容即可。</p>
  <p>（1）&quot;下拉可以刷新&quot;—&gt;&quot;松开立即更新&quot;</p>
  <p>在UIScrollView的委托函数scrollViewDidScroll:中检测用户下拉的程度，达到预设值后就改变状态，如下：</p>
  <div>
    <pre class="prettyprint"><span style="color: #008080;"> 1</span> - (<span style="color: #0000ff;">void</span>)scrollViewDidScroll:(UIScrollView *<span style="color: #000000;">)scrollView
</span><span style="color: #008080;"> 2</span> <span style="color: #000000;">{
</span><span style="color: #008080;"> 3</span>     <span style="color: #008000;">//</span><span style="color: #008000;">拉动足够距离，状态变更为“松开....”</span>
<span style="color: #008080;"> 4</span>     <span style="color: #0000ff;">if</span> (self.shouldShowDragHeader &amp;&amp;<span style="color: #000000;"> dragHeaderView)
</span><span style="color: #008080;"> 5</span> <span style="color: #000000;">    {
</span><span style="color: #008080;"> 6</span>         <span style="color: #0000ff;">if</span> (dragHeaderView.state ==<span style="color: #000000;"> kPull2RefreshViewStateDragToRefresh
</span><span style="color: #008080;"> 7</span>             &amp;&amp; scrollView.contentOffset.y &lt; -self.dragHeaderHeight - <span style="color: #800080;">10</span><span style="color: #000000;">.f
</span><span style="color: #008080;"> 8</span>             &amp;&amp; !<span style="color: #000000;">headerRefreshing
</span><span style="color: #008080;"> 9</span>             &amp;&amp; !<span style="color: #000000;">footerRefreshing)
</span><span style="color: #008080;">10</span> <span style="color: #000000;">        {
</span><span style="color: #008080;">11</span> <span style="color: #000000;">            [dragHeaderView flipImageAnimated:YES];
</span><span style="color: #008080;">12</span> <span style="color: #000000;">            [dragHeaderView setState:kPull2RefreshViewStateLooseToRefresh];
</span><span style="color: #008080;">13</span> <span style="color: #000000;">        }
</span><span style="color: #008080;">14</span> <span style="color: #000000;">    }
</span><span style="color: #008080;">15</span> }</pre>
  </div>
  <p>修改指示箭头方向为向上，在setState中修改状态文本为&quot;松开立即刷新&quot;。</p>
  <p>
    （2）&quot;松开立即刷新&quot;—&gt;&quot;加载中...&quot;    <br/>
    在UIScrollView的委托函数scrollViewDidEndDragging:&nbsp;willDecelerate:中检测用户手指离开屏幕时的情况：  </p>
  <div>
    <pre class="prettyprint"><span style="color: #008080;"> 1</span> - (<span style="color: #0000ff;">void</span>)scrollViewDidEndDragging:(UIScrollView *<span style="color: #000000;">)scrollView willDecelerate:(BOOL)decelerate
</span><span style="color: #008080;"> 2</span> <span style="color: #000000;">{
</span><span style="color: #008080;"> 3</span>         <span style="color: #008000;">//</span><span style="color: #008000;">拉动足够距离，松开后，状态变更为“加载中...”</span>
<span style="color: #008080;"> 4</span>         <span style="color: #0000ff;">if</span> (dragHeaderView.state ==<span style="color: #000000;"> kPull2RefreshViewStateLooseToRefresh
</span><span style="color: #008080;"> 5</span>             &amp;&amp; scrollView.contentOffset.y &lt; -self.dragHeaderHeight - <span style="color: #800080;">10.0f</span><span style="color: #000000;">)
</span><span style="color: #008080;"> 6</span> <span style="color: #000000;">        {
</span><span style="color: #008080;"> 7</span>             <span style="color: #008000;">//</span><span style="color: #008000;">使refresh panel保持显示</span>
<span style="color: #008080;"> 8</span>             self.contentInset = UIEdgeInsetsMake(self.dragHeaderHeight, <span style="color: #800080;">0</span>, <span style="color: #800080;">0</span>, <span style="color: #800080;">0</span><span style="color: #000000;">);
</span><span style="color: #008080;"> 9</span> <span style="color: #000000;">            [dragHeaderView flipImageAnimated:YES];
</span><span style="color: #008080;">10</span> <span style="color: #000000;">            [dragHeaderView setState:kPull2RefreshViewStateRefreshing];
</span><span style="color: #008080;">11</span> <span style="color: #000000;">        }
</span><span style="color: #008080;">12</span> }</pre>
  </div>
  <p>相比1中添加了修改指示箭头方向，在setState中修改状态文本为&quot;加载中...&quot;。</p>
  <p>
    （3）&quot;加载中...&quot;—&gt;&quot;下拉可以刷新&quot;    <br/>
    这一步需要由外部（通常是ViewController）判断何时执行，提供一个方法供外部调用，如下：  </p>
  <div>
    <pre class="prettyprint"><span style="color: #008080;"> 1</span> - (<span style="color: #0000ff;">void</span><span style="color: #000000;">)completeDragRefresh
</span><span style="color: #008080;"> 2</span> <span style="color: #000000;">{
</span><span style="color: #008080;"> 3</span> <span style="color: #000000;">        [UIView beginAnimations:nil context:NULL];
</span><span style="color: #008080;"> 4</span>         [UIView setAnimationDuration:<span style="color: #800080;">0.3f</span><span style="color: #000000;">];
</span><span style="color: #008080;"> 5</span>         self.contentInset =<span style="color: #000000;"> UIEdgeInsetsZero;
</span><span style="color: #008080;"> 6</span> <span style="color: #000000;">        [UIView commitAnimations];
</span><span style="color: #008080;"> 7</span>         
<span style="color: #008080;"> 8</span> <span style="color: #000000;">        [dragView flipImageAnimated:NO];
</span><span style="color: #008080;"> 9</span> <span style="color: #000000;">        [dragView setState:kPull2RefreshViewStateDragToRefresh];
</span><span style="color: #008080;">10</span> }</pre>
  </div>
  <p>指示箭头方向和状态文本恢复为初始状态，更新时间变为当前时间。</p>
  <p>
    <strong>
      <span>3、其他</span>
    </strong>
    <br/>
    <span>
      （1）&quot;下拉刷新&quot;和&quot;上拉加载更多&quot;的不同      <br/>
    </span>
    &quot;下拉刷新&quot;的refresh panel的位置始终不变，而&quot;上拉加载更多&quot;的refresh panel则需要随着tableView.contentSize的变化而变化。一个比较简单的方案是：  </p>
  <div>
    <pre class="prettyprint"><span style="color: #008080;">1</span> tableView.tableFooterView = dragFooterView;</pre>
  </div>
  <p>在某些第三方实现中便是如此处理的，好处是简单到只需要一行代码，坏处是tableFooterView被占用了。考虑到tableFooterView在&quot;上拉加载更多&quot;的情境下不太需要自定义，影响不大。</p>
  <p>另一个方案是在初始化时和数据更新后，设置refresh panel的frame使其始终保持正确位置。</p>
  <p>此外，在触发刷新的条件上，二者也是不同的。&quot;下拉刷新&quot;时，为防止刷新&quot;太过灵敏&quot;，需要设置一个阀值来控制，所以才有&quot;松开立即刷新&quot;。而&quot;上拉加载更多&quot;是在用户往下不断浏览内容的过程中触发的，因此只需滑动到内容底部就立即触发加载。</p>
  <p>UITableView作为派生类，是和基类UIScrollView共享一个delegate属性的，即UITableViewDeleagte和UIScrollViewDelegate是同时指定的。这带来的问题是，想要封装一个支持&quot;下拉刷新&quot;和&quot;上拉加载更多&quot;的UITableView子类，恐怕不得不增加一层委托，将UITableViewDelegate中的各种方法都转到外部进行实现，如</p>
  <div>
    <pre class="prettyprint"><span style="color: #008080;">1</span> - (<span style="color: #0000ff;">void</span>)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *<span style="color: #000000;">)indexPath
</span><span style="color: #008080;">2</span> <span style="color: #000000;">{
</span><span style="color: #008080;">3</span>     <span style="color: #0000ff;">if</span> (self.pullDelegate &amp;&amp;<span style="color: #000000;"> [self.pullDelegate respondsToSelector:@selector(pull2RefreshTableView:didSelectRowAtIndexPath:)])
</span><span style="color: #008080;">4</span> <span style="color: #000000;">    {
</span><span style="color: #008080;">5</span> <span style="color: #000000;">        [self.pullDelegate pull2RefreshTableView:self didSelectRowAtIndexPath:indexPath];
</span><span style="color: #008080;">6</span> <span style="color: #000000;">    }
</span><span style="color: #008080;">7</span> }</pre>
  </div>
  <p>可谓麻烦至极。暂未想到较好的解决方案。【Mark】</p>
  <p>4、封装的Pull2RefreshTableView Demo工程</p>
  <p>使用iOS 6.1 SDK编译，使用ARC。</p>
  <p>
    地址：    <a href="https://github.com/cDigger/CDPullToRefreshDemo" target="_blank" rel="nofollow">https://github.com/cDigger/CDPullToRefreshDemo</a>
  </p>
  <p>1、Scroll View Programming Guide for iOS</p>
  <p>
    <a href="https://developer.apple.com/library/ios/documentation/windowsviews/conceptual/UIScrollView_pg/CreatingBasicScrollViews/CreatingBasicScrollViews.html" target="_blank" rel="nofollow">https://developer.apple.com/library/ios/documentation/windowsviews/conceptual/UIScrollView_pg/CreatingBasicScrollViews/CreatingBasicScrollViews.html</a>
  </p>
  <p>
    <a href="https://github.com/samvermette/SVPullToRefresh" target="_blank" rel="nofollow">https://github.com/samvermette/SVPullToRefresh</a>
  </p>
</div>

        </div>
        <div class="article_social">
        <div class="article_like">
                <button class="btn btn-large btn-like" id="my_like2" data_id="RFzy2a">
                    <i class="icon-heart-empty"></i>
                    赞一个
                </button>
                <button class="btn btn-large btn-fav liked" id="my_like" data_id="RFzy2a">
                    <i class="icon-star-empty"></i>
                    收 藏
                </button>
        </div>
        <div class="bottom_ad huodong-detail-ad-banner clearfix">
            <script type="text/javascript">
    var cpro_id = "u1665123";
</script>
<script src="http://cpro.baidustatic.com/cpro/ui/c.js" type="text/javascript"></script>

        </div>
        </div>
           <div id="site_articles">
              <div class="article-part-title">
                <span>推荐文章</span>
              </div>
          <ul class="side_article_list">
                <li class="side_article_list_item">
                    1.<a href="/articles/NfiiAz" target="_blank" title="IOS之ipad和iphone之间的xib的适配所有的屏幕">
                    IOS之ipad和iphone之间的xib的适配所有的屏幕
                </a>
                </li>
                <li class="side_article_list_item">
                    2.<a href="/articles/ne67zm" target="_blank" title="带缓存功能的视频播放器">
                    带缓存功能的视频播放器
                </a>
                </li>
                <li class="side_article_list_item">
                    3.<a href="/articles/IvuIRbA" target="_blank" title="iOS_Quartz 2D绘图">
                    iOS_Quartz 2D绘图
                </a>
                </li>
                <li class="side_article_list_item">
                    4.<a href="/articles/6rUzeq" target="_blank" title="[iOS]圆形进度条及计时功能">
                    [iOS]圆形进度条及计时功能
                </a>
                </li>
                <li class="side_article_list_item">
                    5.<a href="/articles/z6nUN3" target="_blank" title="iOS事件点击之发生了什么？">
                    iOS事件点击之发生了什么？
                </a>
                </li>
                <li class="side_article_list_item">
                    6.<a href="/articles/UnQvian" target="_blank" title="Xcode 的ARC转化功能以及跟非ARC共存方法">
                    Xcode 的ARC转化功能以及跟非ARC共存方法
                </a>
                </li>
         </ul>
        </div>

        <div id="kan_articles"></div>
        <div id="article_weibo" style="display:none;">
            <div class='article-part-title'>
                <span>相关微博</span>
                <sub>
                    <a href="/articles/weibo_list/RFzy2a" target="_blank">(<i id="weibo_num"></i>)</a> 
               </sub>
            </div>
            <div class="related-weibo-list"></div>
        </div>
        <div class="comments">
    <div class="comments-area">
    <div class="comments-header">
        <h5>我来评几句</h5>
        <div class="alert comment-alert alert-error" style="display:none;">
            错误
        </div>
            <textarea cols="60" rows="5" id="comment-body" placeholder="请输入评论内容..." style="resize: none;"></textarea>
            <span class="btn btn-medium btn-submit"  id="comment-submit">登录后评论</span>
        <p style="margin-top: 5px;margin-left:10px;">
            已发表评论数(<span class="comment_cnt"></span>)
        </p>
    </div>
    <div class="comments-list">
        <div class="empty-cmts alert alert-success" style="display:none;">
            没有更多评论了^^
        </div>
    </div>
    <div class="more-comments" style="display:none;">
        <a href="">更多评论</a>
    </div>
    <div class="load-fail" style="display:none;">
        评论加载失败，<a href="javascript:reload_comments('RFzy2a',1,0,-1);">重新加载</a>
    </div>
    </div>
</div>

    </div>
         <div class="span4 article_right_side">
            
            <div class="right_top">
    <div class="article_related_site article_detail_bg">
    <h4 class="article-part-title">相关站点</h4>
    <div class="article_related_site_body clearfix">
        <div class="logo">
            <img src="http://stimg2.tuicool.com/bAzeYv.png"/>
        </div>
        <div class="name">
            <div>
                <a href="/sites/bAzeYv" target="_blank"> 博客园精华区</a>
            </div>
            <div>
                    <input type="button" class="btn btn-success right_site_follow" value="+&nbsp;订阅" id="my_follow" data_id="bAzeYv"/>
            </div>
        </div>
    </div>
</div>

<div class="right-ad">
      <script type="text/javascript">BAIDU_CLB_fillSlot("1086186");</script>

</div>
<div class="right-ad" style="margin-top: 8px">
      <script type="text/javascript">BAIDU_CLB_fillSlot("1092367");</script>

</div>
<div class="right-ad" style="margin-top: 8px">
      <script type="text/javascript">BAIDU_CLB_fillSlot("1145010");</script>

</div>
<div class="right-ad" style="margin-top: 8px">
      <script type="text/javascript">BAIDU_CLB_fillSlot("1086175");</script>

</div>
<div id="right_site_articles" class="article_detail_bg">
    <div class="article-part-title">
        <span>热门文章</span>
    </div>
    <ul class="side_article_list">
        <li class="side_article_list_item">
            1.<a href="/articles/NfiiAz" target="_blank" title="IOS之ipad和iphone之间的xib的适配所有的屏幕"> IOS之ipad和iphone之间的xib的适配所有的屏幕 </a>
        </li>
        <li class="side_article_list_item">
            2.<a href="/articles/ne67zm" target="_blank" title="带缓存功能的视频播放器"> 带缓存功能的视频播放器 </a>
        </li>
        <li class="side_article_list_item">
            3.<a href="/articles/IvuIRbA" target="_blank" title="iOS_Quartz 2D绘图"> iOS_Quartz 2D绘图 </a>
        </li>
        <li class="side_article_list_item">
            4.<a href="/articles/UnQvian" target="_blank" title="Xcode 的ARC转化功能以及跟非ARC共存方法"> Xcode 的ARC转化功能以及跟非ARC共存方法 </a>
        </li>
        <li class="side_article_list_item">
            5.<a href="/articles/eUrYJzN" target="_blank" title="稀土掘金日报 ： [稀土掘金日报] iOS不能错过的干货合集"> 稀土掘金日报 ： [稀土掘金日报] iOS不能错过的干货合集 </a>
        </li>
        <li class="side_article_list_item">
            6.<a href="/articles/N3Iraef" target="_blank" title="Blocks块编程指南"> Blocks块编程指南 </a>
        </li>
    </ul>
</div>
</div>

<div class="operate_zone">
    <div class="container-body share-body">
        <div class="article-part-title">
            <span>分享本文</span>
        </div>
        <div class="share_zone">
    <div class="bdsharebuttonbox"> 
         <a href="#" class="bds_tsina" data-cmd="tsina" title="分享到新浪微博"></a>
        <a href="#" class="bds_qzone" data-cmd="qzone" title="分享到QQ空间"></a>
        <a href="#" class="bds_tqq" data-cmd="tqq" title="分享到腾讯微博"></a>
        <a href="#" class="bds_renren" data-cmd="renren" title="分享到人人网"></a>
        <a href="#" class="bds_weixin" data-cmd="weixin" title="分享到微信"></a>
        <a href="#" class="bds_more" data-cmd="more"></a>
     </div>
    <script>
        window._bd_share_config = {
            "common" : {
                "bdSnsKey" : {
                    "tsina" : "3113829255",
                    "tqq" : "801536792"
                },
                "bdText" : "UITableView：下拉刷新和上拉加载更多 - cDigger (分享自 @推酷网)",
                "bdMini" : "2",
                "bdMiniList" : false,
                "bdPic" : "http://aimg1.tuicool.com/2qiqMr.png",
                "bdStyle" : "1",
                "bdSize" : "24"
            },
            "share" : {}
        };
        with (document)
        0[(getElementsByTagName('head')[0] || body).appendChild(createElement('script')).src = 'http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion=' + ~(-new Date() / 36e5)];
    </script>
</div>
    </div>
        <div class="frd_pos">
        <script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<ins class="adsbygoogle"
     style="display:inline-block;width:300px;height:250px"
     data-ad-client="ca-pub-7054762349007490"
     data-ad-slot="5705695566"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>

        </div>
</div>
         </div>
</div>

<div id="myLoginModal" class="modal hide fade">
    <div class="modal-header">
        <a class="close" data-dismiss="modal" >&times;</a>
        <h3>用户登录</h3>
    </div>
    <div class="modal-body">
        <form method="post" action="/login" class="form-horizontal" id="login-form">
            <div class="control-group">
                <input id="xlEmail" name="email" type="text" placeholder="邮箱" />
            </div>
            <div class="control-group">
                <input id="xlPassword" name="password" type="password" placeholder="密码"/>
            </div>
            <div class="control-group">
                <button type="submit" class="btn btn-primary">
                    &nbsp;&nbsp;登&nbsp;&nbsp;&nbsp;录&nbsp;&nbsp;
                </button>
            </div>
        </form>
    </div>
</div>

<div class="read-later-alert">
</div>
<div>
   <a href="#add-article-to-kan" id="add-article-to-kan-btn" class="btn" data-toggle="modal" style="display:none;">添加到推刊</a>
   <!-- add_article to kan -->
<div id="add-article-to-kan" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-header">
    <span class="add-title">收藏到推刊</span>
    <a href="#new-kan" class="btn pull-right" data-toggle="modal">创建推刊</a>
    <i class="clearfix"></i>
  </div>
  <div class="modal-body">
    <ul id="add-kan-list">
    </ul>
  </div>
  <div class="modal-footer">
    <input type="hidden" value="RFzy2a" class="article-id" /> 
    <button class="btn btn-primary pull-left add-to-btn">  收 藏  </button>
    <button class="btn" data-dismiss="modal" aria-hidden="true">取消</button>
  </div>
</div>
<div class="add-article-to-kan-alert">
  已收藏到推刊！
</div>

   <div id="new-kan" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-body">
    <input type="text" name="name" id="new-kan-name"  placeholder="推刊名(必填)" required data-validation-required-message="请填写推刊名" />
    <span class="new-ness-name">请填写推刊名</span>
    <br/>
    <textarea name="desc" id="desc" rows="6" placeholder="推刊描述"></textarea>
    <span class="new-ness-desc">描述不能大于100个字符!</span>
    <br/>
    权限设置：<input type="radio" name="type" value="1" checked="checked" /> 公开
    <input type="radio" name="type" value="0"> 仅自己可见
  </div>
  <div class="modal-footer">
    <button class="btn btn-primary pull-left create-kan-btn" disabled>创建</button>
    <button class="btn dismiss-new-kan" data-dismiss="modal" aria-hidden="true">取消</button>
  </div>
</div>


</div>
<style type="text/css">
    .btn-large {
        padding: 0;
    }
    .load-fail {
        display: none;
    }
</style>
<script src="http://static1.tuicool.com//assets/highlight.pack.js"></script>
<script type="text/javascript">
    $('table').each(function(i) {
        var size = $(this).children().size();
        if (size > 1) {
            $(this).attr('class',"table table-bordered");
        } else if (size == 1) {
            var e11 = $(this).children(":first");
            var e1 = e11[0];
            var name = e1.nodeName.toLowerCase();
            if ("tbody" == name) {
                if (e11.children().size() > 1) {
                     $(this).attr('class',"table table-bordered");
                }
            }
        }
    });
            related_kan("RFzy2a");
        window.page = 0;
        window.last = 0;    
        window.first = true;
        resize_article_image('#nei', 550);
                load_comments("RFzy2a",1,0,-1);
                window.uid = -1;
        open_add_article_to_kan("false");
        async_do_like2_article(); 
        $('pre').each(function(i, e) {
            hljs.highlightBlock(e, "<span class='indent'>  </span>", false)
        });
       
          
       handle_follow_site("#my_follow","已订阅","+ 订阅");
</script>


  </div>

    <div class="footer">
    <div class="footer-inner">
    <dl class="about-link site-link">
        <dt>
            网站相关
        </dt>
        <dd>
            <a target="_blank" href="http://www.tuicool.com/about">关于我们</a>
        </dd>
        <dd>
            <a target="_blank" href="http://www.tuicool.com/mobile">移动应用</a>
        </dd>
        <dd>
            <a target="_blank" href="http://www.tuicool.com/bbs/go/issues">建议反馈</a>
        </dd>
    </dl>
    <dl class="site-link follow-link">
        <dt>
            关注我们
        </dt>
        <dd>
            <a target="_blank" href="http://e.weibo.com/tuicool2012"><img src="http://static1.tuicool.com/images/weibo-32.png">推酷网</a>
        </dd>
        <dd><img src="http://static1.tuicool.com/images/weixin-32.png">tuicool2012
        </dd>
        <dd><img src="http://static1.tuicool.com/images/qun-54.png">QQ群:164644910
        </dd>
    </dl>
    <dl class="site-link links">
        <dt>
            友情链接
        </dt>
        <dd>
                <a href="http://www.woshipm.com/" title="人人都是产品经理" target="_blank">人人都是产品经理</a>
                <a href="http://www.tmtforum.com/" title="TMTForum" target="_blank">TMTForum</a>
                <a href="http://www.moobuu.com/" title="魔部网" target="_blank">魔部网</a>
                <a href="http://www.pm265.com/" title="PM256" target="_blank">PM256</a>
                <a href="http://www.pintu360.com/" title="品途网" target="_blank">品途网</a>
                <a href="http://www.yidonghua.com/" title="移动信息化" target="_blank">移动信息化</a>
                <a href="http://www.snsiu.com/" title="行晓网" target="_blank">行晓网</a>
                <a href="http://code4app.com/" title="Code4App" target="_blank">Code4App</a>
                <a href="http://www.taskcity.com/" title="智城外包网" target="_blank">智城外包网</a>
                <a href="http://blog.lamper.cn/" title="LAMP人" target="_blank">LAMP人</a>
                <a href="http://www.apkway.com/forum.php" title="安卓航班网" target="_blank">安卓航班网</a>
                <a href="http://www.huxiu.com/" title="虎嗅" target="_blank">虎嗅</a>
                <a href="http://www.ycpai.com/" title="缘创派" target="_blank">缘创派</a>
                <a href="http://www.iterduo.com/" title="IT耳朵" target="_blank">IT耳朵</a>
                <a href="http://www.iresearch.cn/" title="艾瑞网" target="_blank">艾瑞网</a>
                <a href="http://mediaworks.caixin.com/" title="创媒工场" target="_blank">创媒工场</a>
                <a href="http://www.leiphone.com/" title="雷锋网" target="_blank">雷锋网</a>
                <a href="http://www.managershare.com/" title="经理人分享" target="_blank">经理人分享</a>
                <a href="http://www.shichangbu.com/" title="市场部网" target="_blank">市场部网</a>
                <a href="http://www.ikanchai.com/" title="砍柴网" target="_blank">砍柴网</a>
                <a href="http://www.cocoachina.com/" title="CocoaChina" target="_blank">CocoaChina</a>
                <a href="http://www.ibeifeng.com/" title="北风网" target="_blank">北风网</a>
                <a href="http://www.jiankongbao.com/" title="云智慧" target="_blank">云智慧</a>
                <a href="http://www.wyzc.com" title="我赢职场" target="_blank">我赢职场</a>
                <a href="http://www.thebigdata.cn/" title="大数据时代" target="_blank">大数据时代</a>
                <a href="http://www.qidic.com/" title="奇笛网" target="_blank">奇笛网</a>
                <a href="http://www.cngulu.com/" title="咕噜网" target="_blank">咕噜网</a>
                <a href="http://www.linuxdiyf.com/" title="红联linux" target="_blank">红联linux</a>
                <a href="http://win10.ithome.com" title="Win10之家" target="_blank">Win10之家</a>
                <a href="http://www.niaogebiji.com/" title="鸟哥笔记" target="_blank">鸟哥笔记</a>
                <a href="http://www.play.cn" title="爱游戏" target="_blank">爱游戏</a>
                <a href="http://www.investide.cn/" title="投资潮" target="_blank">投资潮</a>
                <a href="http://www.31huiyi.com/" title="31会议网" target="_blank">31会议网</a>
                <a href="https://www.jpush.cn/" title="极光推送" target="_blank">极光推送</a>
                <a href="https://www.teambition.com/" title="Teambition" target="_blank">Teambition</a>
                <a href="http://cn.cocos2d-x.org/ " title="Cocos引擎中文官网" target="_blank">Cocos引擎中文官网</a>
                <a href="http://www.guigu.org/" title="硅谷网" target="_blank">硅谷网</a>
            <a href="/links">更多链接>></a>&nbsp;&nbsp;
        </dd>
    </dl>
    <div class="clear"></div>
    </div>
</div>

<div style="display:none;">
   <script src="http://s22.cnzz.com/stat.php?id=5541078&web_id=5541078&show=pic" language="JavaScript"></script>
</div>


</body>
</html>
